package com.rslai.commons.validator.jsonvalidator.validators;

import org.junit.Assert;

import java.util.List;

import static com.rslai.commons.validator.jsonvalidator.matchers.Required.required;

/**
 * JSON校验器，required校验器
 */
public class RequiredValidator extends Validator {
    public static final String VALIDATOR_NAME = "required";

    /**
     * 构造函数
     * @param args args
     */
    RequiredValidator(List<Object> args) {

    }

    /**
     * 校验JSON对象
     * @param object 待验证的JSON对象
     */
	@Override
	public void doValidate(Object object) {
        Assert.assertThat("this object is required.", object, required());
    }

    /**
     * 返回校验名称
     * @return 校验名称
     */
	@Override
	public String name() {
        return VALIDATOR_NAME;
	}

}
